using UnityEngine;
using System.Collections;

public class StateTorreAtack : State<TorretaControl>   {

    static StateTorreAtack m_instance = new StateTorreAtack();
    public static StateTorreAtack instance { get { return m_instance; } }
   
    public override void OnEnter(TorretaControl behaviour)
    {
        Debug.Log("TORRE: Empiezo a atacar");
		
		VampiroControl vc = behaviour.enemigoActual.GetComponent("VampiroControl") as VampiroControl;
		vc.SumoAtacante(behaviour.transform);	
//		behaviour.enemigoActual.SendMessage("SumoAtacante", behaviour.transform);
		behaviour.time = Time.timeSinceLevelLoad;
		behaviour.cuerpoTorre.LookAt(behaviour.enemigoActual);
    }

    public override void OnUpdate(TorretaControl behaviour)
    {  	
    	behaviour.cuerpoTorre.LookAt(behaviour.enemigoActual);
		if ((behaviour.time + behaviour.ATACKSPEED) < Time.timeSinceLevelLoad)
        {
            behaviour.time = Time.timeSinceLevelLoad;

            behaviour.Disparar();
			//behaviour.State = StateTorreLook.instance;
        }
    }

    public override void OnExit(TorretaControl behaviour)
    {
        Debug.Log("TORRE: Termino de atacar");
    }

    public override void OnAction(string name, TorretaControl behaviour, object value)
    {

    }

}
